package com.wj.ballcat.admin.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.hccake.ballcat.admin.upms.config.mybatis.MybatisPlusConfig;
import com.tangzc.mpe.condition.DynamicConditionInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author WJ
 */
@Configuration
public class MpConfig extends MybatisPlusConfig {

	@Override
	@Bean
	@ConditionalOnMissingBean(MybatisPlusInterceptor.class)
	public MybatisPlusInterceptor mybatisPlusInterceptor() {
		MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
		interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
		// 添加动态条件，若同时添加了其他的拦截器，继续添加即可
		interceptor.addInnerInterceptor(new DynamicConditionInterceptor());
		return interceptor;
	}
}
